import socket
# https://www.bilibili.com/video/BV1wD4y1o7AS?p=172&spm_id_from=pageDriver&vd_source=bb634e2de31ba429e83805555d8dca83
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
while True:
    data = input("客户：")
    client_socket.sendto(data.encode(), ("127.0.0.1", 8887))
    if data == "exit":
        break
    data, server_address = client_socket.recvfrom(1024)
    print("客服：", data.decode())

client_socket.close()
